<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>18、不用函数柯里化实现</title>
</head>
<body>
    <div id="test"></div>

    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <script type="text/javascript" src="../js/prop-types.js"></script>
    
    <script type="text/babel"> 
        class Login extends React.Component{
            state = {
                username: '',
                password: ''
            }
            render(){
                return (
                    <form onSubmit={this.handleSubmit}>
                        用户名：<input onChange={(event) => {this.saveFormData('username',event.target.value)}} type="text" name="username" /><br />
                        密码：<input onChange={(event) => {this.saveFormData('password',event.target.value)}} type="password" name="password" /><br />
                        <button>登录</button>
                    </form>
                ) 
            }
            saveFormData = (dataType,value) => {
                this.setState({[dataType]:value})
            }
            handleSubmit = (event) => {
                event.preventDefault();
                const {username,password} = this.state
                alert(`你输入的用户名是：${username}，你输入的密码是：${password}`)
            }
        }
        ReactDOM.render(<Login />,document.getElementById('test'))
    </script>
</body>
</html>